package com.tianhui.consignortwofei.mvp.ui.adapter;

import android.content.Context;

import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.fgs.common.widget.itemView.ClickItemView;
import com.fgs.common.widget.itemView.InputItemView;
import com.tianhui.consignortwofei.R;
import com.tianhui.consignortwofei.mvp.model.QuotationListBean;


import org.yczbj.ycrefreshviewlib.adapter.RecyclerArrayAdapter;
import org.yczbj.ycrefreshviewlib.holder.BaseViewHolder;

import java.util.List;

/**
 * @author fei
 * @date 2023/12/20
 * @description
 */
public class QuotationDetailItemAdapter extends RecyclerArrayAdapter<QuotationListBean.QuotationRecords.PlasticsQuotationListDTO> {




    private List<QuotationListBean.QuotationRecords.PlasticsQuotationListDTO> list;
    private Context mContext;
    public String selectedItem;
    private int totalVotes;
    private  int lookType;

    public QuotationDetailItemAdapter(Context context, String selectedItem, int totalVotes) {//, IOrderStatus iOrderStatus
        super(context);
        this.mContext = context;
        this.selectedItem = selectedItem;
        this.totalVotes = totalVotes;
    }

    public QuotationDetailItemAdapter(Context context, List<QuotationListBean.QuotationRecords.PlasticsQuotationListDTO> listBeans,int lookType) {//, IOrderStatus iOrderStatus
        super(context);
        this.mContext = context;
        list=listBeans;
        this.lookType=lookType;
    }




    @Override
    public BaseViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) {
        OrderListViewHolder viewHolder = new OrderListViewHolder(parent, R.layout.item_quotation_detail);
//        OrderListViewHolder viewHolder = new OrderListViewHolder(parent, R.layout.item_quotation_detail_two);
        return viewHolder;
//        switch (viewType) {
//            case 0:
//                return new newsBigImgViewHolder(parent, R.layout.item_news_big);
//            case 1:
//                return new newsSmallImgViewHolder(parent, R.layout.item_news_small);
//            case 2:
//                return new newsThreeViewHolder(parent, R.layout.item_news_three_image);
//        }
//        return null;


    }



    public class OrderListViewHolder extends BaseViewHolder<QuotationListBean.QuotationRecords.PlasticsQuotationListDTO> {
//        private TextView numberTextView;

        ClickItemView civ_paihao;
        ClickItemView civ_liexing;
        ClickItemView civ_huanquan;

        InputItemView iiv_num;
        InputItemView iiv_price;
        InputItemView iiv_quyu;
        InputItemView iiv_cangku;
        InputItemView iiv_name;
        InputItemView iiv_phone;
        InputItemView iiv_beizhu;

        TextView tv_change;
        TextView tv_delete;


//        private HomeListAdapter homeListAdapter;



        public OrderListViewHolder(ViewGroup parent, int res) {
            super(parent, res);
//            numberTextView = getView(R.id.item_order_list_numberTextView);

            civ_paihao = (ClickItemView) getView(R.id.civ_paihao);
            civ_liexing = (ClickItemView) getView(R.id.civ_liexing);
            civ_huanquan = (ClickItemView) getView(R.id.civ_huanquan);

            iiv_num = (InputItemView) getView(R.id.iiv_num);
            iiv_price = (InputItemView) getView(R.id.iiv_price);
            iiv_quyu = (InputItemView) getView(R.id.iiv_quyu);
            iiv_cangku = (InputItemView) getView(R.id.iiv_cangku);
            iiv_name = (InputItemView) getView(R.id.iiv_name);
            iiv_phone = (InputItemView) getView(R.id.iiv_phone);
            iiv_beizhu = (InputItemView) getView(R.id.iiv_beizhu);

            tv_change = (TextView) getView(R.id.tv_change);
            tv_delete = (TextView) getView(R.id.tv_delete);


            addOnClickListener(R.id.tv_change);
            addOnClickListener(R.id.tv_delete);
//
//            addOnClickListener(R.id.iv_head);
//            addOnClickListener(R.id.tv_user_name);


        }

        @Override
        public void setData(QuotationListBean.QuotationRecords.PlasticsQuotationListDTO data) {
            super.setData(data);

            civ_paihao.setContent(data.getMfrname()+"|"+data.getName()+"|"+data.getProducer());
            civ_liexing.setContent(data.getTypename());
            civ_huanquan.setContent(data.getOwnershipname());

            iiv_num.setContent(data.getNumber());
            iiv_price.setContent(data.getPrice());
            iiv_quyu.setContent(data.getSalesarea());
            iiv_cangku.setContent(data.getWarehouse());
            iiv_name.setContent(data.getContacts());
            iiv_phone.setContent(data.getPhone());
            iiv_beizhu.setContent(data.getRemarks());


            if (1==lookType){
                tv_change.setVisibility(View.VISIBLE);
                tv_delete.setVisibility(View.VISIBLE);
            }else {
                tv_change.setVisibility(View.GONE);
                tv_delete.setVisibility(View.GONE);
            }



        }


    }






}
